#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS 1
#endif

#include<bits/stdc++.h>
using namespace std;
/*
http://ybt.ssoier.cn:8088/problem_show.php?pid=1297
*/

int main() {
	string st1, st2;
	while (cin >> st1 >> st2) {
		st1 = '_' + st1; st2 = '_' + st2;
		vector<vector<int> >dp(st1.size(), vector<int>(st2.size(), 0));
		for (int i = 1; i < st1.size(); i++) {
			for (int j = 1; j < st2.size(); j++) {
				if (st1[i] == st2[j])
					dp[i][j] = dp[i - 1][j - 1] + 1;
				else
					dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			}
		}
		cout << dp[st1.size()-1][st2.size()-1]<<endl;
	}
	return 0;
}